package com.slaffka.mapper;

import com.slaffka.model.Page;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * _User: v.tsapaev
 * Date: 18.02.12
 * Time: 13:21
 * To change this template use File | Settings | File Templates.
 */
public interface PageMapper {

//    final String SELECT_PAGE = "SELECT p.page_id, p.name, p.title, p.content, p.url, p.description, p.is_visible " +
//            "FROM page p " +
//            "left join page_type pt on pt.page_type_id = p.page_type_id";
    @Select(value = "SELECT * FROM page p")
    @Results({
        @Result(property = "pageId", column = "page_id")
    })
    public List<Page> getAllPages();

    @Select(value = "SELECT * FROM page WHERE url = #{url}")
    @Results({
            @Result(property = "pageId", column = "page_id")
    })
    Page getPageByUrl(String url);
}
